// javamaps
// Copyright (c) 2010 Lup Gratian
package Rendering.Animations;
import Rendering.*;
import Core.*;

public final class ZoomAnimation extends AnimationBase {
    private View current_;
    MapViewer viewer_;
    double xPerc_;
    double yPerc_;
    double startZoom_;
    double endZoom_;

    /*
     * Constructori.
     */
    public ZoomAnimation(IAnimatable parent, View current,
                        double origXPerc, double origYPerc, double endZoom,
                        long duration, IInterpolation interpolation){
        super(parent, duration, interpolation);
        viewer_ = (MapViewer)parent;
        current_ = current;
        xPerc_ = origXPerc;
        yPerc_ = origYPerc;
        startZoom_ = current.Zoom();
        endZoom_ = endZoom;
    }

    /*
     * Metode publice.
     */
    @Override
    public void Update() {
        double zoom = Interpolation().GetValue(startZoom_, endZoom_, Progress());
        viewer_.ApplyZoomStep(xPerc_, yPerc_, zoom);
    }

    @Override
    public void Start() {
        StartWatch();
    }

    public double StartZoom() { return startZoom_; }
    public double EndZoom() { return startZoom_; }
    public double DeltaZoom() { return endZoom_ - startZoom_; }
}